# models/product.py
from enum import Enum


class ProductType(Enum):
    PACKAGE = "套餐"
    GOODS = "商品"
    SERVICE = "服务"


class Product:
    def __init__(self, name, product_type, price, unit):
        self.name = name
        self.type = product_type
        self.base_price = price  # 单价
        self.unit = unit
        self.quantity = 1        # 默认数量

    def set_amount(self, quantity):
        """设置购买数量，返回新对象保持immutable特性"""
        new_product = Product(self.name, self.type, self.base_price, self.unit)
        new_product.quantity = quantity
        return new_product

    @property
    def total_price(self):
        """计算总价"""
        return self.base_price * self.quantity
